
const baseUrl = "http://bufantec.com"

function request(data) {
  return new Promise((resolve, reject) => {
    if (data.method == 'get' || null) {
      uni.request({
        url: baseUrl + data.url,
        data: data.data,
        success: res => {
          resolve(res)
        },
        fail: err => {
          reject(err)
        }
      })
    } else if (data.method == 'post') {
      uni.request({
        url:baseUrl +data.url,
        data: data.data,
        method: data.method,
        header: data.header,
        success: res => {
          resolve(res)
        },
        fail: err => {
          reject(err)
        }
      })
    }
  })
}

export default request;